import request from '@/utils/request';

// 分页查询
export function listItem(tableCode, params, data) {
  return request({
    url: `/web/bu/form/curd/${tableCode}/page`,
    method: 'post',
    params,
    data,
  });
}

// 查询详情
export function getItem(tableCode, data) {
  return request({
    url: `/web/bu/form/curd/${tableCode}/info`,
    method: 'post',
    data,
  });
}

// 保存数据
export function addItem(tableCode, data) {
  return request({
    url: `/web/bu/form/curd/${tableCode}/save`,
    method: 'post',
    data,
  });
}

// 修改数据
export function updateItem(tableCode, data) {
  return request({
    url: `/web/bu/form/curd/${tableCode}/edit`,
    method: 'post',
    data,
  });
}

// 删除数据
export function delItem(tableCode, data) {
  return request({
    url: `/web/bu/form/curd/${tableCode}/delete`,
    method: 'post',
    data,
  });
}

// 下载导出模板
export function downloadTpl(tableCode, filename) {
  return request({
    url: `/web/bu/form/curd/${tableCode}/template`,
    method: 'get',
    responseType: 'blob',
    filename,
  });
}

// 导出数据
export function exportData(tableCode, params, data, filename) {
  return request({
    url: `/web/bu/form/curd/${tableCode}/export`,
    method: 'post',
    responseType: 'blob',
    filename,
  });
}

// 导入数据
export function importData(tableCode, data) {
  return request({
    url: `/web/bu/form/curd/${tableCode}/import`,
    method: 'post',
    data,
  });
}
